package cn.iocoder.yudao.module.contract.dal.mysql.basicData;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.contract.dal.dataobject.basicData.BasicBankDO;
import cn.iocoder.yudao.module.contract.dal.dataobject.basicData.BasicPackingDO;
import cn.iocoder.yudao.module.contract.dal.dataobject.invoice.InvoiceDO;
import cn.iocoder.yudao.module.contract.utils.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.contract.controller.admin.basicData.vo.*;

/**
 * 银行信息 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface BasicBankMapper extends BaseMapperX<BasicBankDO> {

    default PageResult<BasicBankDO> selectPage(BasicBankPageReqVO reqVO) {
        return selectPage(reqVO, new MPJLambdaWrapperX<BasicBankDO>()
                .eqIfPresent(BasicBankDO::getCompanyCode, reqVO.getCompanyCode())
                .likeIfPresent(BasicBankDO::getCompanyName, reqVO.getCompanyName())
                .eqIfPresent(BasicBankDO::getCode, reqVO.getCode())
                .likeIfPresent(BasicBankDO::getName, reqVO.getName())
                .likeIfPresent(BasicBankDO::getBankName, reqVO.getBankName())
                .eqIfPresent(BasicBankDO::getBankAddress, reqVO.getBankAddress())
                .eqIfPresent(BasicBankDO::getBankCode, reqVO.getBankCode())
                .eqIfPresent(BasicBankDO::getBankAccount, reqVO.getBankAccount())
                .betweenIfPresent(BasicBankDO::getCreateTime, reqVO.getCreateTime())
                .in(!ObjectUtils.isEmpty(reqVO.getCompanyCodeList()), BasicBankDO::getCompanyCode, Arrays.asList(!ObjectUtils.isEmpty(reqVO.getCompanyCodeList())?reqVO.getCompanyCodeList():new Object[]{""}))
                .orderByDesc(ObjectUtils.isEmpty(reqVO.getOrder()), BasicPackingDO::getCreateTime)
                .orderBy(ObjectUtils.isNotEmpty(reqVO.getOrder()),"ascending".equals(reqVO.getOrder()), StringUtils.toUnderScoreCase(reqVO.getProp())));
    }

}